package com.yunji.base.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.base.dao.ISiteLocationDao;
import com.yunji.base.params.SiteLocationParam;
import com.yunji.base.vo.SiteLocationVO;
import com.yunji.common.model.domain.SiteLocationDO;
import com.yunji.base.mapper.ISiteLocationMapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;


@Repository
public class SiteLocationDaoImpl extends BaseDaoImpl<ISiteLocationMapper, SiteLocationDO> implements ISiteLocationDao {

    @Override
    public boolean existsLocationType(List<Long> list) {
        return lambdaQuery().in(SiteLocationDO::getLocationTypeId,list).exists();
    }

    @Override
    public List<SiteLocationDO> getLocationPageList(SiteLocationParam param) {
        return pageList(param,new LambdaQueryWrapper<SiteLocationDO>()
                .eq(BeanUtils.isNotNull(param.getLocationId()),SiteLocationDO::getLocationId,param.getLocationId())
                .eq(BeanUtils.isNotNull(param.getBelongId()),SiteLocationDO::getBelongId,param.getBelongId()));
    }
}
